package com.yanqu.road.server.cmd.grandchild.exam;

import com.yanqu.road.pb.grandchild.GrandChildProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.grandchild.GrandChildMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_GRAND_CHILD_GET_IMPERIAL_EXAM_RESULT, desc = "请求科举结果")
public class GetImperialExamResultCmd extends AbstractCommand {

    private GrandChildProto.ExamResultRewardReqMsg reqMsg;

    private String examNo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = GrandChildProto.ExamResultRewardReqMsg.parseFrom(packet.getBytes());
        examNo = reqMsg.getNo();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        // 记录观看状态
        GrandChildMgr.readUserExamResult(player, examNo);
        // 发跨服
        player.sendPacket(CrossProtocol.C_GRAND_CHILD_GET_IMPERIAL_EXAM_RESULT, reqMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
